﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using TongCheng.API.OpenAPI.Domain;
using TongCheng.API.OpenAPI.Request;
using TongCheng.API.OpenAPI.Response;
using TongCheng.API.OpenAPI.Util;

namespace TongCheng.API.OpenAPI.Facade
{
    public static class HotelFacade
    {
        /// <summary>
        /// 获取酒店房型预订策略
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelBookingPolicyResponse GetHotelBookingPolicy(GetHotelBookingPolicyRequest request)
        {
            GetHotelBookingPolicyResponse response = new GetHotelBookingPolicyResponse();
            response.Body.hotelBookingPolicy = new HotelBookingPolicy();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse hotelBookingPolicy
            response.Body.hotelBookingPolicy.payType = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/payType");
            response.Body.hotelBookingPolicy.payFirstDayFlag = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/payFirstDayFlag");
            response.Body.hotelBookingPolicy.payRate = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/payRate");
            response.Body.hotelBookingPolicy.fullYearFlag = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/fullYearFlag");
            response.Body.hotelBookingPolicy.beginDate = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/beginDate");
            response.Body.hotelBookingPolicy.endDate = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/endDate");
            response.Body.hotelBookingPolicy.fullDayFlag = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/fullDayFlag");
            response.Body.hotelBookingPolicy.overTime = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/overTime");
            response.Body.hotelBookingPolicy.overRoomsFlag = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/overRoomsFlag");
            response.Body.hotelBookingPolicy.weekDate = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/weekDate");
            response.Body.hotelBookingPolicy.cancelDays = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/cancelDays");
            response.Body.hotelBookingPolicy.cancelTime = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/cancelTime");
            response.Body.hotelBookingPolicy.changeDays = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/changeDays");
            response.Body.hotelBookingPolicy.changeTime = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/changeTime");
            response.Body.hotelBookingPolicy.bookingPolicyDes = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/bookingPolicyDes");
            response.Body.hotelBookingPolicy.cancelPolicyDes = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/cancelPolicyDes");

            response.Body.hotelBookingPolicy.danBaoType = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/danBaoType");
            response.Body.hotelBookingPolicy.description = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/description");
            response.Body.hotelBookingPolicy.isTomorrow = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/isTomorrow");
            response.Body.hotelBookingPolicy.lastCancelTime = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/lastCancelTime");
            response.Body.hotelBookingPolicy.lastChangeTime = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/lastChangeTime");
            response.Body.hotelBookingPolicy.overRooms = Tools.GetXmlDocumentInnerText(doc, "body/hotelBookingPolicy/overRooms");
            #endregion

            return response;
        }

        /// <summary>
        /// 获取酒店详情
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelDetailResponse GetHotelDetail(GetHotelDetailRequest request)
        {
            GetHotelDetailResponse response = new GetHotelDetailResponse();
            response.Body.hotelInfo = new HotelInfo();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse header
            response.Body.hotelInfo.hotelId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/hotelId", 0);
            response.Body.hotelInfo.hotelName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/hotelName");

            response.Body.hotelInfo.starRated = new StarRated();
            response.Body.hotelInfo.starRated.starRatedId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/starRated/starRatedId", 0);
            response.Body.hotelInfo.starRated.starRatedName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/starRated/starRatedName");

            response.Body.hotelInfo.city = new City();
            response.Body.hotelInfo.city.cityId = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/city/cityId");
            response.Body.hotelInfo.city.cityName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/city/cityName");

            response.Body.hotelInfo.section = new Section();
            response.Body.hotelInfo.section.sectionId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/section/sectionId", 0);
            response.Body.hotelInfo.section.sectionName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/section/sectionName");

            response.Body.hotelInfo.chain = new Chain();
            response.Body.hotelInfo.chain.chainId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/chain/chainId", 0);
            response.Body.hotelInfo.chain.chainName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/chain/chainName");

            response.Body.hotelInfo.bizSection = new BizSection();
            response.Body.hotelInfo.bizSection.bizSectionId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/bizSection/bizSectionId", 0);
            response.Body.hotelInfo.bizSection.bizSectionName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/bizSection/bizSectionName");

            response.Body.hotelInfo.street = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/street");
            response.Body.hotelInfo.streetAddr = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/streetAddr");
            response.Body.hotelInfo.nearby = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/nearby");

            response.Body.hotelInfo.impressList = new ImpressList();
            response.Body.hotelInfo.impressList.Items = new List<Impression>();
            XmlNodeList impressListNodeList = doc.SelectNodes("impressList/item");
            for (int i = 0; i < impressListNodeList.Count; i++)
            {
                var impressListNode = impressListNodeList[i];
                var impress = new Impression();
                impress.impressionId = Tools.GetXmlNodeAttributeToInt(impressListNode, "", "id", 0);
                impress.impressionName = Tools.GetXmlNodeInnerText(impressListNode, "");
                response.Body.hotelInfo.impressList.Items.Add(impress);
            }


            response.Body.hotelInfo.openingDate = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/openingDate");
            response.Body.hotelInfo.decoDate = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/decoDate");
            response.Body.hotelInfo.additionalService = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/additionalService");
            response.Body.hotelInfo.service = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/service");
            response.Body.hotelInfo.facility = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/facility");
            response.Body.hotelInfo.catering = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/catering");
            response.Body.hotelInfo.recreation = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/recreation");
            response.Body.hotelInfo.creditCard = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/creditCard");
            response.Body.hotelInfo.intro = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/intro");
            response.Body.hotelInfo.longitude = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/longitude");
            response.Body.hotelInfo.latitude = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/latitude");
            response.Body.hotelInfo.remark = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/remark");
            response.Body.hotelInfo.lowestPrice = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/lowestPrice");
            response.Body.hotelInfo.highestPrice = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/highestPrice");

            response.Body.hotelInfo.commentCount = new CommentCount();
            response.Body.hotelInfo.commentCount.commentTotal = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/commentCount/commentTotal", 0);
            response.Body.hotelInfo.commentCount.commentGood = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/commentCount/commentGood", 0);
            response.Body.hotelInfo.commentCount.commentMid = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/commentCount/commentMid", 0);
            response.Body.hotelInfo.commentCount.commentBad = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/commentCount/commentBad", 0);
            #endregion

            return response;
        }

        /// <summary>
        /// 获取酒店房型担保政策
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetGuaranteePolicyResponse GetGuaranteePolicy(GetGuaranteePolicyRequest request)
        {
            GetGuaranteePolicyResponse response = new GetGuaranteePolicyResponse();
            response.Body.hotelBookPolicyList = new HotelBookPolicyList();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse hotelBookingPolicy
            response.Body.hotelBookPolicyList.Items = new List<HotelBookingPolicy>();
            XmlNodeList hotelBookPolicyNodeList = doc.SelectNodes("//hotelBookPolicy");
            for (int i = 0; i < hotelBookPolicyNodeList.Count; i++)
            {
                var hotelBookPolicyNode = hotelBookPolicyNodeList[i];
                var hotelBookPolicy = new HotelBookingPolicy();

                hotelBookPolicy.payType = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/payType").InnerText;
                hotelBookPolicy.payFirstDayFlag = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/payFirstDayFlag").InnerText;
                hotelBookPolicy.payRate = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/payRate").InnerText;
                hotelBookPolicy.fullYearFlag = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/fullYearFlag").InnerText;
                hotelBookPolicy.beginDate = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/beginDate").InnerText;
                hotelBookPolicy.endDate = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/endDate").InnerText;
                hotelBookPolicy.fullDayFlag = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/fullDayFlag").InnerText;
                hotelBookPolicy.overTime = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/overTime").InnerText;
                hotelBookPolicy.overRoomsFlag = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/overRoomsFlag").InnerText;
                hotelBookPolicy.weekDate = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/weekDate").InnerText;
                hotelBookPolicy.cancelDays = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/cancelDays").InnerText;
                hotelBookPolicy.cancelTime = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/cancelTime").InnerText;
                hotelBookPolicy.changeDays = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/changeDays").InnerText;
                hotelBookPolicy.changeTime = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/changeTime").InnerText;
                hotelBookPolicy.bookingPolicyDes = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/bookingPolicyDes").InnerText;
                hotelBookPolicy.cancelPolicyDes = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/cancelPolicyDes").InnerText;

                hotelBookPolicy.danBaoType = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/danBaoType").InnerText;
                hotelBookPolicy.description = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/description").InnerText;
                hotelBookPolicy.isTomorrow = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/isTomorrow").InnerText;
                hotelBookPolicy.lastCancelTime = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/lastCancelTime").InnerText;
                hotelBookPolicy.lastChangeTime = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/lastChangeTime").InnerText;
                hotelBookPolicy.overRooms = hotelBookPolicyNode.SelectSingleNode("body/hotelBookingPolicy/overRooms").InnerText;
                response.Body.hotelBookPolicyList.Items.Add(hotelBookPolicy);
            }
            #endregion

            return response;
        }

        /// <summary>
        /// 获取酒店图片列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelImageListResponse GetHotelImageList(GetHotelImageListRequest request)
        {
            GetHotelImageListResponse response = new GetHotelImageListResponse();
            response.Body.extInfoOfImageList = new ExtInfoOfImageList();
            response.Body.hotelImageList = new HotelImageList();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse hotelist
            XmlNode hotelImageListNode = doc.SelectSingleNode("//hotelImageList");
            response.Body.hotelImageList.page = Tools.StrToInt(hotelImageListNode.Attributes["page"].Value, 0);
            response.Body.hotelImageList.pageSize = Tools.StrToInt(hotelImageListNode.Attributes["pageSize"].Value, 0);
            response.Body.hotelImageList.totalPage = Tools.StrToInt(hotelImageListNode.Attributes["totalPage"].Value, 0);
            response.Body.hotelImageList.totalCount = Tools.StrToInt(hotelImageListNode.Attributes["totalCount"].Value, 0);
            response.Body.hotelImageList.imgBaseUrl = hotelImageListNode.Attributes["imgBaseUrl"].Value;
            response.Body.hotelImageList.Items = new List<HotelImage>();

            XmlNodeList hotelImageNodeList = doc.SelectNodes("//hotelImage");
            for (var i = 0; i < hotelImageNodeList.Count; i++)
            {
                var node = hotelImageNodeList[i];
                var hotelImage = new HotelImage();
                hotelImage.imageId = Tools.StrToInt(node.SelectSingleNode("imageId").InnerText, 0);
                hotelImage.imageName = node.SelectSingleNode("imageName").InnerText;
                hotelImage.imageUrl = node.SelectSingleNode("imageUrl").InnerText;
                response.Body.hotelImageList.Items.Add(hotelImage);
            }
            #endregion

            #region parse extInfoOfImageList
            response.Body.extInfoOfImageList.sizeCodeList = new SizeCodeList();
            response.Body.extInfoOfImageList.sizeCodeListWatermark = new SizeCodeListWatermark();
            XmlNode extInfoOfImageListNode = doc.SelectSingleNode("//extInfoOfImageList");
            response.Body.extInfoOfImageList.imageBaseUrl = extInfoOfImageListNode.SelectSingleNode("imageBaseUrl").InnerText;

            response.Body.extInfoOfImageList.sizeCodeList.Items = new List<SizeCode>();
            XmlNodeList sizeCodeListNode = extInfoOfImageListNode.SelectNodes("sizeCodeList/sizeCode");
            for (var j = 0; j < sizeCodeListNode.Count; j++)
            {
                XmlNode sizeCodeNode = sizeCodeListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeList.Items.Add(sc);
            }

            response.Body.extInfoOfImageList.sizeCodeListWatermark.Items = new List<SizeCode>();
            XmlNodeList sizeCodeWatermarkListNode = extInfoOfImageListNode.SelectNodes("sizeCodeListWatermark/sizeCode");
            for (var j = 0; j < sizeCodeWatermarkListNode.Count; j++)
            {
                XmlNode sizeCodeWatermarkNode = sizeCodeWatermarkListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeWatermarkNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeListWatermark.Items.Add(sc);
            }
            #endregion

            return response;
        }

        /// <summary>
        /// 酒店多ID获取返回信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelInfoMultiResponse GetHotelInfoMulti(GetHotelInfoMultiRequest request)
        {
            GetHotelInfoMultiResponse response = new GetHotelInfoMultiResponse();
            response.Body.hotelList = new HotelList();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse hotelist
            response.Body.hotelList.Items = new List<Hotel>();

            XmlNodeList hotelNodes = doc.SelectNodes("//hotel");
            for (var i = 0; i < hotelNodes.Count; i++)
            {
                var node = hotelNodes[i];
                TongCheng.API.OpenAPI.Domain.Hotel h = new Hotel();
                h.hotelId = Tools.StrToInt(node.SelectSingleNode("hotelId").InnerText, 0);
                h.hotelName = node.SelectSingleNode("hotelName").InnerText;
                h.intro = node.SelectSingleNode("intro").InnerText;
                h.oneWord = node.SelectSingleNode("oneWord").InnerText;
                h.address = node.SelectSingleNode("address").InnerText;
                h.nearBy = node.SelectSingleNode("nearBy").InnerText;
                h.street = node.SelectSingleNode("street").InnerText;
                h.streetAddr = node.SelectSingleNode("streetAddr").InnerText;
                h.img = node.SelectSingleNode("img").InnerText;
                h.groupBuy = node.SelectSingleNode("groupBuy").InnerText;
                h.roomType = Tools.StrToInt(node.SelectSingleNode("roomType").InnerText, 0);
                h.createDate = node.SelectSingleNode("createDate").InnerText;
                h.viewCount = node.SelectSingleNode("viewCount").InnerText;
                h.recmdLevel = node.SelectSingleNode("recmdLevel").InnerText;
                h.lowestPrice = node.SelectSingleNode("lowestPrice").InnerText;
                h.highestPrice = node.SelectSingleNode("highestPrice").InnerText;
                h.longitude = node.SelectSingleNode("longitude").InnerText;
                h.latitude = node.SelectSingleNode("latitude").InnerText;
                h.bonusRate = node.SelectSingleNode("bonusRate").InnerText;
                h.thumbUrl = node.SelectSingleNode("thumbUrl").InnerText;

                h.city = new City();
                h.section = new Section();
                h.bizSection = new BizSection();
                h.bizSection.bizSectionId = Tools.GetXmlNodeInnerTextToInt(node, "bizSection/bizSectionId", 0);
                h.bizSection.bizSectionName = node.SelectSingleNode("bizSection/bizSectionName").InnerText;

                h.starRated = new StarRated();
                h.starRated.starRatedId = Tools.StrToInt(node.SelectSingleNode("starRated/starRatedId").InnerText, 0);
                h.starRated.starRatedClass = node.SelectSingleNode("starRated/starRatedClass") == null ? "" : node.SelectSingleNode("starRated/starRatedId").InnerText;
                h.starRated.starRatedName = node.SelectSingleNode("starRated/starRatedName") == null ? "" : node.SelectSingleNode("starRated/starRatedName").InnerText;

                h.commentCount = new CommentCount();
                h.commentCount.commentTotal = Tools.StrToInt(node.SelectSingleNode("commentCount/commentTotal") == null ? "0" : node.SelectSingleNode("commentCount/commentTotal").InnerText, 0);
                h.commentCount.commentGood = Tools.StrToInt(node.SelectSingleNode("commentCount/commentGood") == null ? "0" : node.SelectSingleNode("commentCount/commentGood").InnerText, 0);
                h.commentCount.commentMid = Tools.StrToInt(node.SelectSingleNode("commentCount/commentMid") == null ? "0" : node.SelectSingleNode("commentCount/commentMid").InnerText, 0);
                h.commentCount.commentBad = Tools.StrToInt(node.SelectSingleNode("commentCount/commentBad") == null ? "0" : node.SelectSingleNode("commentCount/commentBad").InnerText, 0);

                h.remark = node.SelectSingleNode("remark").InnerText;
                response.Body.hotelList.Items.Add(h);

            }
            #endregion

            return response;
        }

        /// <summary>
        /// 获取酒店列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelListResponse GetHotelList(GetHotelListRequest request)
        {
            GetHotelListResponse response = new GetHotelListResponse();
            response.Body.hotelList = new HotelList();
            response.Body.extInfoOfImageList = new ExtInfoOfImageList();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime"); 
            if (response.Header.rspCode == "0001")
            {
                return response;
            }
            #endregion

            #region parse hotelist
            XmlNode hotelListNode = doc.SelectSingleNode("//hotelList");
            response.Body.hotelList.page = Tools.GetXmlNodeAttributeToInt(hotelListNode, "", "page", 0);
            response.Body.hotelList.pageSize = Tools.GetXmlNodeAttributeToInt(hotelListNode, "", "pageSize", 0);
            response.Body.hotelList.totalPage = Tools.GetXmlNodeAttributeToInt(hotelListNode, "", "totalPage", 0);
            response.Body.hotelList.totalCount = Tools.GetXmlNodeAttributeToInt(hotelListNode, "", "totalCount", 0);
            response.Body.hotelList.imageBaseUrl = hotelListNode.Attributes["imageBaseUrl"].Value;
            response.Body.hotelList.Items = new List<Hotel>();

            XmlNodeList hotelNodes = doc.SelectNodes("//hotel");
            for (var i = 0; i < hotelNodes.Count; i++)
            {
                var node = hotelNodes[i];
                TongCheng.API.OpenAPI.Domain.Hotel h = new Hotel();
                h.hotelId = Tools.GetXmlNodeInnerTextToInt(node, "hotelId", 0);
                h.hotelName = Tools.GetXmlNodeInnerText(node, "hotelName");
                h.intro = Tools.GetXmlNodeInnerText(node, "intro");
                h.oneWord = Tools.GetXmlNodeInnerText(node, "oneWord");
                h.address = Tools.GetXmlNodeInnerText(node, "address");
                h.nearBy = Tools.GetXmlNodeInnerText(node, "nearBy");
                h.street = Tools.GetXmlNodeInnerText(node, "street");
                h.streetAddr = Tools.GetXmlNodeInnerText(node, "streetAddr");
                h.img = Tools.GetXmlNodeInnerText(node, "img");
                h.groupBuy = Tools.GetXmlNodeInnerText(node, "groupBuy");
                h.roomType = Tools.StrToInt(node.SelectSingleNode("roomType"), 0);
                h.createDate = Tools.GetXmlNodeInnerText(node, "createDate");
                h.viewCount = Tools.GetXmlNodeInnerText(node, "viewCount");
                h.recmdLevel = Tools.GetXmlNodeInnerText(node, "recmdLevel");
                h.lowestPrice = Tools.GetXmlNodeInnerText(node, "lowestPrice");
                h.highestPrice = Tools.GetXmlNodeInnerText(node, "highestPrice");
                h.longitude = Tools.GetXmlNodeInnerText(node, "longitude");
                h.latitude = Tools.GetXmlNodeInnerText(node, "latitude");
                h.bonusRate = Tools.GetXmlNodeInnerText(node, "bonusRate");
                h.city = new City();
                h.section = new Section();
                //h.bizSection = node.SelectSingleNode("bizSection").InnerText;
                //h.chain = node.SelectSingleNode("chain").InnerText;
                h.starRated = new StarRated();
                h.starRated.starRatedId = Tools.GetXmlNodeInnerTextToInt(node, "starRated/starRatedId", 0);
                h.starRated.starRatedClass = Tools.GetXmlNodeInnerText(node, "starRated/starRatedClass");
                h.starRated.starRatedName = Tools.GetXmlNodeInnerText(node, "starRated/starRatedName");

                h.commentCount = new CommentCount();
                h.commentCount.commentTotal = Tools.GetXmlNodeInnerTextToInt(node, "commentCount/commentTotal", 0);
                h.commentCount.commentGood = Tools.GetXmlNodeInnerTextToInt(node, "commentCount/commentGood", 0);
                h.commentCount.commentMid = Tools.GetXmlNodeInnerTextToInt(node, "commentCount/commentMid", 0);
                h.commentCount.commentBad = Tools.GetXmlNodeInnerTextToInt(node, "commentCount/commentBad", 0);

                h.cpList = new CpList();
                h.cpList.Cps = new List<Cp>();
                XmlNodeList cpListNode = node.SelectNodes("cpList/cp");
                for (var j = 0; j < cpListNode.Count; j++)
                {
                    XmlNode cpNode = cpListNode[j];
                    Cp cp = new Cp();
                    cp.point = Tools.GetXmlNodeInnerText(cpNode, "point");
                    cp.dec = Tools.GetXmlNodeInnerText(cpNode, "dec");
                    h.cpList.Cps.Add(cp);
                }

                h.remark = Tools.GetXmlNodeInnerText(node, "remark");
                response.Body.hotelList.Items.Add(h);

            }
            #endregion

            #region parse extInfoOfImageList
            response.Body.extInfoOfImageList.sizeCodeList = new SizeCodeList();
            response.Body.extInfoOfImageList.sizeCodeListWatermark = new SizeCodeListWatermark();
            XmlNode extInfoOfImageListNode = doc.SelectSingleNode("//extInfoOfImageList");
            response.Body.extInfoOfImageList.imageBaseUrl = extInfoOfImageListNode.SelectSingleNode("imageBaseUrl").InnerText;

            response.Body.extInfoOfImageList.sizeCodeList.Items = new List<SizeCode>();
            XmlNodeList sizeCodeListNode = extInfoOfImageListNode.SelectNodes("sizeCodeList/sizeCode");
            for (var j = 0; j < sizeCodeListNode.Count; j++)
            {
                XmlNode sizeCodeNode = sizeCodeListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeList.Items.Add(sc);
            }

            response.Body.extInfoOfImageList.sizeCodeListWatermark.Items = new List<SizeCode>();
            XmlNodeList sizeCodeWatermarkListNode = extInfoOfImageListNode.SelectNodes("sizeCodeListWatermark/sizeCode");
            for (var j = 0; j < sizeCodeWatermarkListNode.Count; j++)
            {
                XmlNode sizeCodeWatermarkNode = sizeCodeWatermarkListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeWatermarkNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeListWatermark.Items.Add(sc);
            }
            #endregion

            return response;
        }

        /// <summary>
        /// 获取多个酒店房型信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelRoomsMultiResponse GetHotelRoomsMulti(GetHotelRoomsMultiRequest request)
        {
            GetHotelRoomsMultiResponse response = new GetHotelRoomsMultiResponse();
            response.Body.hotellist = new List<Hoteldata>();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);


            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            XmlNodeList hoteldataNodeList = doc.SelectNodes("//hoteldata");
            for (int i = 0; i < hoteldataNodeList.Count; i++)
            {
                var hoteldataNode = hoteldataNodeList[i];
                var hoteldata = new Hoteldata();
                hoteldata.hotelInfo = new HotelInfo();
                hoteldata.hotelRoomList = new HotelRoomList();
                hoteldata.extInfoOfImageList = new ExtInfoOfImageList();

                #region parse hotelInfo
                hoteldata.hotelInfo.hotelId = Tools.GetXmlNodeInnerTextToInt(hoteldataNode, "hotelInfo/hotelId", 0);
                hoteldata.hotelInfo.hotelName = Tools.GetXmlNodeInnerText(hoteldataNode, "hotelInfo/hotelName");
                hoteldata.hotelInfo.hotelType = Tools.GetXmlNodeInnerText(hoteldataNode, "hotelInfo/hotelType");
                hoteldata.hotelInfo.hotelCode = Tools.GetXmlNodeInnerText(hoteldataNode, "hotelInfo/hotelCode");
                hoteldata.hotelInfo.hotelChainId = Tools.GetXmlNodeInnerTextToInt(hoteldataNode, "hotelInfo/hotelChainId", 0);
                #endregion

                #region parse hotelRoomList
                hoteldata.hotelRoomList.hotelId = Tools.GetXmlNodeAttributeToInt(hoteldataNode, "hotelRoomList", "hotelId", 0);
                hoteldata.hotelRoomList.imageBaseUrl = Tools.GetXmlNodeAttribute(hoteldataNode, "hotelRoomList", "imageBaseUrl");
                hoteldata.hotelRoomList.page = Tools.GetXmlNodeAttributeToInt(hoteldataNode, "hotelRoomList", "page", 0);
                hoteldata.hotelRoomList.pageSize = Tools.GetXmlNodeAttributeToInt(hoteldataNode, "hotelRoomList", "pageSize", 0);
                hoteldata.hotelRoomList.totalPage = Tools.GetXmlNodeAttributeToInt(hoteldataNode, "hotelRoomList", "totalPage", 0);
                hoteldata.hotelRoomList.totalCount = Tools.GetXmlNodeAttributeToInt(hoteldataNode, "hotelRoomList", "totalCount", 0);

                hoteldata.hotelRoomList.Items = new List<HotelRoomInfo>();
                XmlNodeList hotelRoomInfoNodeList = hoteldataNode.SelectNodes("hotelRoomList/hotelRoomInfo");
                for (var j = 0; j < hotelRoomInfoNodeList.Count; j++)
                {
                    XmlNode hotelRoomInfoNode = hotelRoomInfoNodeList[i];
                    HotelRoomInfo hotelRoomInfo = new HotelRoomInfo();
                    hotelRoomInfo.roomTypeId = Tools.GetXmlNodeInnerTextToInt(hotelRoomInfoNode, "roomTypeId", 0);
                    hotelRoomInfo.roomName = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "roomName");
                    hotelRoomInfo.roomCount = Tools.GetXmlNodeInnerTextToInt(hotelRoomInfoNode, "roomCount", 0);
                    hotelRoomInfo.bed = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "bed");
                    hotelRoomInfo.bedWidth = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "bedWidth");
                    hotelRoomInfo.allowAddBed = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "allowAddBed");
                    hotelRoomInfo.allowAddBedRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "allowAddBedRemark");
                    hotelRoomInfo.breakfast = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "breakfast");
                    hotelRoomInfo.area = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "area");
                    hotelRoomInfo.floor = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "floor");
                    hotelRoomInfo.adsl = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "adsl");
                    hotelRoomInfo.adslRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "adslRemark");
                    hotelRoomInfo.noSmoking = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "noSmoking");
                    hotelRoomInfo.ownBath = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "ownBath");
                    hotelRoomInfo.photoUrl = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "photoUrl");
                    hotelRoomInfo.roomTypeRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "roomTypeRemark");
                    hotelRoomInfo.certificateType = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "certificateType");

                    hotelRoomInfo.pricePolicyList = new PricePolicyList();
                    hotelRoomInfo.pricePolicyList.Items = new List<PricePolicyInfo>();
                    XmlNodeList pricePolicyNodeList = hotelRoomInfoNode.SelectNodes("pricePolicyList/pricePolicyInfo");
                    for (var k = 0; k < pricePolicyNodeList.Count; k++)
                    {
                        XmlNode pricePolicyNode = pricePolicyNodeList[k];
                        PricePolicyInfo ppi = new PricePolicyInfo();
                        ppi.policyId = pricePolicyNode.SelectSingleNode("policyId") == null ? "" : pricePolicyNode.SelectSingleNode("policyId").InnerText;
                        ppi.policyName = pricePolicyNode.SelectSingleNode("policyName") == null ? "" : pricePolicyNode.SelectSingleNode("policyName").InnerText;
                        ppi.roomAdviceAmount = pricePolicyNode.SelectSingleNode("roomAdviceAmount") == null ? "" : pricePolicyNode.SelectSingleNode("roomAdviceAmount").InnerText;
                        ppi.roomPrize = pricePolicyNode.SelectSingleNode("roomPrize") == null ? "" : pricePolicyNode.SelectSingleNode("roomPrize").InnerText;
                        ppi.roomBreakfast = pricePolicyNode.SelectSingleNode("roomBreakfast") == null ? "" : pricePolicyNode.SelectSingleNode("roomBreakfast").InnerText;
                        ppi.roomStatus = pricePolicyNode.SelectSingleNode("roomStatus") == null ? "" : pricePolicyNode.SelectSingleNode("roomStatus").InnerText;
                        ppi.roomUndetermined = pricePolicyNode.SelectSingleNode("roomUndetermined") == null ? "" : pricePolicyNode.SelectSingleNode("roomUndetermined").InnerText;
                        ppi.roomuUndeterminedTotal = pricePolicyNode.SelectSingleNode("roomuUndeterminedTotal") == null ? "" : pricePolicyNode.SelectSingleNode("roomuUndeterminedTotal").InnerText;
                        ppi.roomStatusTotal = pricePolicyNode.SelectSingleNode("roomStatusTotal") == null ? "" : pricePolicyNode.SelectSingleNode("roomStatusTotal").InnerText;
                        ppi.avgAmount = pricePolicyNode.SelectSingleNode("avgAmount") == null ? "" : pricePolicyNode.SelectSingleNode("avgAmount").InnerText;
                        ppi.bookingCode = pricePolicyNode.SelectSingleNode("bookingCode") == null ? "" : pricePolicyNode.SelectSingleNode("bookingCode").InnerText;

                        ppi.continuous = new Continuous();
                        ppi.continuous.continuousType = pricePolicyNode.SelectSingleNode("continuous/continuousType") == null ? "" : pricePolicyNode.SelectSingleNode("continuous/continuousType").InnerText;
                        ppi.continuous.continuousFreeDays = pricePolicyNode.SelectSingleNode("continuous/continuousFreeDays") == null ? "" : pricePolicyNode.SelectSingleNode("continuous/continuousFreeDays").InnerText;
                        ppi.continuous.continuousType = pricePolicyNode.SelectSingleNode("continuous/continuousType") == null ? "" : pricePolicyNode.SelectSingleNode("continuous/continuousType").InnerText;

                        ppi.present = new Present();
                        ppi.present.presentFlag = pricePolicyNode.SelectSingleNode("present/presentFlag") == null ? "" : pricePolicyNode.SelectSingleNode("present/presentFlag").InnerText;
                        ppi.present.description = pricePolicyNode.SelectSingleNode("present/description") == null ? "" : pricePolicyNode.SelectSingleNode("present/description").InnerText;
                        ppi.present.endTime = pricePolicyNode.SelectSingleNode("present/endTime") == null ? "" : pricePolicyNode.SelectSingleNode("present/endTime").InnerText;
                        ppi.present.startTime = pricePolicyNode.SelectSingleNode("present/startTime") == null ? "" : pricePolicyNode.SelectSingleNode("present/startTime").InnerText;

                        ppi.guaranteeInfo = pricePolicyNode.SelectSingleNode("guaranteeInfo") == null ? "" : pricePolicyNode.SelectSingleNode("guaranteeInfo").InnerText;
                        ppi.guaranteeType = pricePolicyNode.SelectSingleNode("guaranteeType") == null ? "" : pricePolicyNode.SelectSingleNode("guaranteeType").InnerText;
                        ppi.policyRemark = pricePolicyNode.SelectSingleNode("policyRemark") == null ? "" : pricePolicyNode.SelectSingleNode("policyRemark").InnerText;
                        ppi.guaranteeFlag = pricePolicyNode.SelectSingleNode("guaranteeFlag") == null ? "" : pricePolicyNode.SelectSingleNode("guaranteeFlag").InnerText;
                        ppi.bookingFlag = pricePolicyNode.SelectSingleNode("bookingFlag") == null ? "" : pricePolicyNode.SelectSingleNode("bookingFlag").InnerText;

                        hotelRoomInfo.pricePolicyList.Items.Add(ppi);
                    }
                    hoteldata.hotelRoomList.Items.Add(hotelRoomInfo);
                }
                #endregion

                #region parse extInfoOfImageList
                hoteldata.extInfoOfImageList.sizeCodeList = new SizeCodeList();
                hoteldata.extInfoOfImageList.sizeCodeListWatermark = new SizeCodeListWatermark();
                XmlNode extInfoOfImageListNode = doc.SelectSingleNode("//extInfoOfImageList");
                hoteldata.extInfoOfImageList.imageBaseUrl = extInfoOfImageListNode.SelectSingleNode("imageBaseUrl").InnerText;

                hoteldata.extInfoOfImageList.sizeCodeList.Items = new List<SizeCode>();
                XmlNodeList sizeCodeListNode = extInfoOfImageListNode.SelectNodes("sizeCodeList/sizeCode");
                for (var j = 0; j < sizeCodeListNode.Count; j++)
                {
                    XmlNode sizeCodeNode = sizeCodeListNode[j];
                    SizeCode sc = new SizeCode();
                    sc.text = sizeCodeNode.InnerText;
                    hoteldata.extInfoOfImageList.sizeCodeList.Items.Add(sc);
                }

                hoteldata.extInfoOfImageList.sizeCodeListWatermark.Items = new List<SizeCode>();
                XmlNodeList sizeCodeWatermarkListNode = extInfoOfImageListNode.SelectNodes("sizeCodeListWatermark/sizeCode");
                for (var j = 0; j < sizeCodeWatermarkListNode.Count; j++)
                {
                    XmlNode sizeCodeWatermarkNode = sizeCodeWatermarkListNode[j];
                    SizeCode sc = new SizeCode();
                    sc.text = sizeCodeWatermarkNode.InnerText;
                    hoteldata.extInfoOfImageList.sizeCodeListWatermark.Items.Add(sc);
                }
                #endregion

                response.Body.hotellist.Add(hoteldata);
            }
            return response;
        }

        /// <summary>
        /// 获取房型信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelRoomsResponse GetHotelRooms(GetHotelRoomsRequest request)
        {
            GetHotelRoomsResponse response = new GetHotelRoomsResponse();
            response.Body.hotelInfo = new HotelInfo();
            response.Body.hotelRoomList = new HotelRoomList();
            response.Body.extInfoOfImageList = new ExtInfoOfImageList();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse hotelInfo
            response.Body.hotelInfo.hotelId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/hotelId", 0);
            response.Body.hotelInfo.hotelName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/hotelName");
            response.Body.hotelInfo.hotelType = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/hotelType");
            response.Body.hotelInfo.hotelCode = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/hotelCode");
            response.Body.hotelInfo.hotelChainId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/hotelChainId", 0);
            #endregion

            #region parse hotelRoomList
            response.Body.hotelRoomList.hotelId = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "hotelId", 0);
            response.Body.hotelRoomList.imageBaseUrl = Tools.GetXmlDocumentAttribute(doc, "body/hotelRoomList", "imageBaseUrl");
            response.Body.hotelRoomList.page = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "page", 0);
            response.Body.hotelRoomList.pageSize = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "pageSize", 0);
            response.Body.hotelRoomList.totalPage = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "totalPage", 0);
            response.Body.hotelRoomList.totalCount = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "totalCount", 0);

            response.Body.hotelRoomList.Items = new List<HotelRoomInfo>();
            XmlNodeList hotelRoomInfoNodeList = doc.SelectNodes("//hotelRoomInfo");
            for (var i = 0; i < hotelRoomInfoNodeList.Count; i++)
            {
                XmlNode hotelRoomInfoNode = hotelRoomInfoNodeList[i];
                HotelRoomInfo hotelRoomInfo = new HotelRoomInfo();
                hotelRoomInfo.roomTypeId = Tools.GetXmlNodeInnerTextToInt(hotelRoomInfoNode, "roomTypeId", 0);
                hotelRoomInfo.roomName = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "roomName");
                hotelRoomInfo.roomCount = Tools.GetXmlNodeInnerTextToInt(hotelRoomInfoNode, "roomCount", 0);
                hotelRoomInfo.bed = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "bed");
                hotelRoomInfo.bedWidth = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "bedWidth");
                hotelRoomInfo.allowAddBed = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "allowAddBed");
                hotelRoomInfo.allowAddBedRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "allowAddBedRemark");
                hotelRoomInfo.breakfast = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "breakfast");
                hotelRoomInfo.area = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "area");
                hotelRoomInfo.floor = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "floor");
                hotelRoomInfo.adsl = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "adsl");
                hotelRoomInfo.adslRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "adslRemark");
                hotelRoomInfo.noSmoking = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "noSmoking");
                hotelRoomInfo.ownBath = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "ownBath");
                hotelRoomInfo.photoUrl = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "photoUrl");
                hotelRoomInfo.roomTypeRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "roomTypeRemark");
                hotelRoomInfo.certificateType = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "certificateType");

                hotelRoomInfo.pricePolicyList = new PricePolicyList();
                hotelRoomInfo.pricePolicyList.Items = new List<PricePolicyInfo>();
                XmlNodeList pricePolicyNodeList = hotelRoomInfoNode.SelectNodes("pricePolicyList/pricePolicyInfo");
                for (var j = 0; j < pricePolicyNodeList.Count; j++)
                {
                    XmlNode pricePolicyNode = pricePolicyNodeList[j];
                    PricePolicyInfo ppi = new PricePolicyInfo();
                    ppi.policyId = Tools.GetXmlNodeInnerText(pricePolicyNode, "policyId");
                    ppi.policyName = Tools.GetXmlNodeInnerText(pricePolicyNode, "policyName");
                    ppi.roomAdviceAmount = Tools.GetXmlNodeInnerText(pricePolicyNode, "roomAdviceAmount");
                    ppi.roomPrize = Tools.GetXmlNodeInnerText(pricePolicyNode, "roomPrize");
                    ppi.roomBreakfast = Tools.GetXmlNodeInnerText(pricePolicyNode, "roomBreakfast");
                    ppi.roomStatus = Tools.GetXmlNodeInnerText(pricePolicyNode, "roomStatus");
                    ppi.roomUndetermined = Tools.GetXmlNodeInnerText(pricePolicyNode, "roomUndetermined");
                    ppi.roomuUndeterminedTotal = Tools.GetXmlNodeInnerText(pricePolicyNode, "roomuUndeterminedTotal");
                    ppi.roomStatusTotal = Tools.GetXmlNodeInnerText(pricePolicyNode, "roomStatusTotal");
                    ppi.avgAmount = Tools.GetXmlNodeInnerText(pricePolicyNode, "avgAmount");
                    ppi.bookingCode = Tools.GetXmlNodeInnerText(pricePolicyNode, "bookingCode");

                    ppi.continuous = new Continuous();
                    ppi.continuous.continuousType = Tools.GetXmlNodeInnerText(pricePolicyNode, "continuous/continuousType");
                    ppi.continuous.continuousFreeDays = Tools.GetXmlNodeInnerText(pricePolicyNode, "continuous/continuousFreeDays");
                    ppi.continuous.continuousType = Tools.GetXmlNodeInnerText(pricePolicyNode, "continuous/continuousType");

                    ppi.present = new Present();
                    ppi.present.presentFlag = Tools.GetXmlNodeInnerText(pricePolicyNode, "present/presentFlag");
                    ppi.present.description = Tools.GetXmlNodeInnerText(pricePolicyNode, "present/description");
                    ppi.present.endTime = Tools.GetXmlNodeInnerText(pricePolicyNode, "present/endTime");
                    ppi.present.startTime = Tools.GetXmlNodeInnerText(pricePolicyNode, "present/startTime");

                    ppi.guaranteeInfo = Tools.GetXmlNodeInnerText(pricePolicyNode, "guaranteeInfo");
                    ppi.guaranteeType = Tools.GetXmlNodeInnerText(pricePolicyNode, "guaranteeType");
                    ppi.policyRemark = Tools.GetXmlNodeInnerText(pricePolicyNode, "policyRemark");
                    ppi.guaranteeFlag = Tools.GetXmlNodeInnerText(pricePolicyNode, "guaranteeFlag");
                    ppi.bookingFlag = Tools.GetXmlNodeInnerText(pricePolicyNode, "bookingFlag");

                    hotelRoomInfo.pricePolicyList.Items.Add(ppi);
                }
                response.Body.hotelRoomList.Items.Add(hotelRoomInfo);
            }
            #endregion

            #region parse extInfoOfImageList
            response.Body.extInfoOfImageList.sizeCodeList = new SizeCodeList();
            response.Body.extInfoOfImageList.sizeCodeListWatermark = new SizeCodeListWatermark();
            XmlNode extInfoOfImageListNode = doc.SelectSingleNode("//extInfoOfImageList");
            response.Body.extInfoOfImageList.imageBaseUrl = Tools.GetXmlNodeInnerText(extInfoOfImageListNode, "imageBaseUrl");

            response.Body.extInfoOfImageList.sizeCodeList.Items = new List<SizeCode>();
            XmlNodeList sizeCodeListNode = extInfoOfImageListNode.SelectNodes("sizeCodeList/sizeCode");
            for (var j = 0; j < sizeCodeListNode.Count; j++)
            {
                XmlNode sizeCodeNode = sizeCodeListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeList.Items.Add(sc);
            }

            response.Body.extInfoOfImageList.sizeCodeListWatermark.Items = new List<SizeCode>();
            XmlNodeList sizeCodeWatermarkListNode = extInfoOfImageListNode.SelectNodes("sizeCodeListWatermark/sizeCode");
            for (var j = 0; j < sizeCodeWatermarkListNode.Count; j++)
            {
                XmlNode sizeCodeWatermarkNode = sizeCodeWatermarkListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeWatermarkNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeListWatermark.Items.Add(sc);
            }
            #endregion

            return response;
        }

        /// <summary>
        /// 获取房型价格[包含担保政策] 
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelRoomsWithGuaranteePolicyResponse GetHotelRoomsWithGuaranteePolicy(GetHotelRoomsWithGuaranteePolicyRequest request)
        {
            GetHotelRoomsWithGuaranteePolicyResponse response = new GetHotelRoomsWithGuaranteePolicyResponse();
            response.Body.hotelInfo = new HotelInfo();
            response.Body.hotelRoomList = new HotelRoomList();
            response.Body.extInfoOfImageList = new ExtInfoOfImageList();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse hotelInfo
            response.Body.hotelInfo.hotelId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/hotelId", 0);
            response.Body.hotelInfo.hotelName = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/hotelName");
            response.Body.hotelInfo.hotelType = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/hotelType");
            response.Body.hotelInfo.hotelCode = Tools.GetXmlDocumentInnerText(doc, "body/hotelInfo/hotelCode");
            response.Body.hotelInfo.hotelChainId = Tools.GetXmlDocumentInnerTextToInt(doc, "body/hotelInfo/hotelChainId", 0);
            #endregion

            #region parse hotelRoomList
            response.Body.hotelRoomList.hotelId = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "hotelId", 0);
            response.Body.hotelRoomList.imageBaseUrl = Tools.GetXmlDocumentAttribute(doc, "body/hotelRoomList", "imageBaseUrl");
            response.Body.hotelRoomList.page = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "page", 0);
            response.Body.hotelRoomList.pageSize = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "pageSize", 0);
            response.Body.hotelRoomList.totalPage = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "totalPage", 0);
            response.Body.hotelRoomList.totalCount = Tools.GetXmlDocumentAttributeToInt(doc, "body/hotelRoomList", "totalCount", 0);

            response.Body.hotelRoomList.Items = new List<HotelRoomInfo>();
            XmlNodeList hotelRoomInfoNodeList = doc.SelectNodes("//hotelRoomInfo");
            for (var i = 0; i < hotelRoomInfoNodeList.Count; i++)
            {
                XmlNode hotelRoomInfoNode = hotelRoomInfoNodeList[i];
                HotelRoomInfo hotelRoomInfo = new HotelRoomInfo();
                hotelRoomInfo.roomTypeId = Tools.GetXmlNodeInnerTextToInt(hotelRoomInfoNode, "roomTypeId", 0);
                hotelRoomInfo.roomName = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "roomName");
                hotelRoomInfo.roomCount = Tools.GetXmlNodeInnerTextToInt(hotelRoomInfoNode, "roomCount", 0);
                hotelRoomInfo.bed = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "bed");
                hotelRoomInfo.bedWidth = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "bedWidth");
                hotelRoomInfo.allowAddBed = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "allowAddBed");
                hotelRoomInfo.allowAddBedRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "allowAddBedRemark");
                hotelRoomInfo.breakfast = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "breakfast");
                hotelRoomInfo.area = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "area");
                hotelRoomInfo.floor = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "floor");
                hotelRoomInfo.adsl = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "adsl");
                hotelRoomInfo.adslRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "adslRemark");
                hotelRoomInfo.noSmoking = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "noSmoking");
                hotelRoomInfo.ownBath = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "ownBath");
                hotelRoomInfo.photoUrl = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "photoUrl");
                hotelRoomInfo.roomTypeRemark = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "roomTypeRemark");
                hotelRoomInfo.certificateType = Tools.GetXmlNodeInnerText(hotelRoomInfoNode, "certificateType");

                hotelRoomInfo.pricePolicyList = new PricePolicyList();
                hotelRoomInfo.pricePolicyList.Items = new List<PricePolicyInfo>();
                XmlNodeList pricePolicyNodeList = hotelRoomInfoNode.SelectNodes("pricePolicyList/pricePolicyInfo");
                for (var j = 0; j < pricePolicyNodeList.Count; j++)
                {
                    XmlNode pricePolicyNode = pricePolicyNodeList[j];
                    PricePolicyInfo ppi = new PricePolicyInfo();
                    ppi.policyId = pricePolicyNode.SelectSingleNode("policyId") == null ? "" : pricePolicyNode.SelectSingleNode("policyId").InnerText;
                    ppi.policyName = pricePolicyNode.SelectSingleNode("policyName") == null ? "" : pricePolicyNode.SelectSingleNode("policyName").InnerText;
                    ppi.roomAdviceAmount = pricePolicyNode.SelectSingleNode("roomAdviceAmount") == null ? "" : pricePolicyNode.SelectSingleNode("roomAdviceAmount").InnerText;
                    ppi.roomPrize = pricePolicyNode.SelectSingleNode("roomPrize") == null ? "" : pricePolicyNode.SelectSingleNode("roomPrize").InnerText;
                    ppi.roomBreakfast = pricePolicyNode.SelectSingleNode("roomBreakfast") == null ? "" : pricePolicyNode.SelectSingleNode("roomBreakfast").InnerText;
                    ppi.roomStatus = pricePolicyNode.SelectSingleNode("roomStatus") == null ? "" : pricePolicyNode.SelectSingleNode("roomStatus").InnerText;
                    ppi.roomUndetermined = pricePolicyNode.SelectSingleNode("roomUndetermined") == null ? "" : pricePolicyNode.SelectSingleNode("roomUndetermined").InnerText;
                    ppi.roomuUndeterminedTotal = pricePolicyNode.SelectSingleNode("roomuUndeterminedTotal") == null ? "" : pricePolicyNode.SelectSingleNode("roomuUndeterminedTotal").InnerText;
                    ppi.roomStatusTotal = pricePolicyNode.SelectSingleNode("roomStatusTotal") == null ? "" : pricePolicyNode.SelectSingleNode("roomStatusTotal").InnerText;
                    ppi.avgAmount = pricePolicyNode.SelectSingleNode("avgAmount") == null ? "" : pricePolicyNode.SelectSingleNode("avgAmount").InnerText;
                    ppi.bookingCode = pricePolicyNode.SelectSingleNode("bookingCode") == null ? "" : pricePolicyNode.SelectSingleNode("bookingCode").InnerText;

                    ppi.continuous = new Continuous();
                    ppi.continuous.continuousType = pricePolicyNode.SelectSingleNode("continuous/continuousType") == null ? "" : pricePolicyNode.SelectSingleNode("continuous/continuousType").InnerText;
                    ppi.continuous.continuousFreeDays = pricePolicyNode.SelectSingleNode("continuous/continuousFreeDays") == null ? "" : pricePolicyNode.SelectSingleNode("continuous/continuousFreeDays").InnerText;
                    ppi.continuous.continuousType = pricePolicyNode.SelectSingleNode("continuous/continuousType") == null ? "" : pricePolicyNode.SelectSingleNode("continuous/continuousType").InnerText;

                    ppi.present = new Present();
                    ppi.present.presentFlag = pricePolicyNode.SelectSingleNode("present/presentFlag") == null ? "" : pricePolicyNode.SelectSingleNode("present/presentFlag").InnerText;
                    ppi.present.description = pricePolicyNode.SelectSingleNode("present/description") == null ? "" : pricePolicyNode.SelectSingleNode("present/description").InnerText;
                    ppi.present.endTime = pricePolicyNode.SelectSingleNode("present/endTime") == null ? "" : pricePolicyNode.SelectSingleNode("present/endTime").InnerText;
                    ppi.present.startTime = pricePolicyNode.SelectSingleNode("present/startTime") == null ? "" : pricePolicyNode.SelectSingleNode("present/startTime").InnerText;

                    ppi.guaranteeInfo = pricePolicyNode.SelectSingleNode("guaranteeInfo") == null ? "" : pricePolicyNode.SelectSingleNode("guaranteeInfo").InnerText;
                    ppi.guaranteeType = pricePolicyNode.SelectSingleNode("guaranteeType") == null ? "" : pricePolicyNode.SelectSingleNode("guaranteeType").InnerText;
                    ppi.policyRemark = pricePolicyNode.SelectSingleNode("policyRemark") == null ? "" : pricePolicyNode.SelectSingleNode("policyRemark").InnerText;
                    ppi.guaranteeFlag = pricePolicyNode.SelectSingleNode("guaranteeFlag") == null ? "" : pricePolicyNode.SelectSingleNode("guaranteeFlag").InnerText;
                    ppi.bookingFlag = pricePolicyNode.SelectSingleNode("bookingFlag") == null ? "" : pricePolicyNode.SelectSingleNode("bookingFlag").InnerText;

                    hotelRoomInfo.pricePolicyList.Items.Add(ppi);
                }
                response.Body.hotelRoomList.Items.Add(hotelRoomInfo);
            }
            #endregion

            #region parse extInfoOfImageList
            response.Body.extInfoOfImageList.sizeCodeList = new SizeCodeList();
            response.Body.extInfoOfImageList.sizeCodeListWatermark = new SizeCodeListWatermark();
            XmlNode extInfoOfImageListNode = doc.SelectSingleNode("//extInfoOfImageList");
            response.Body.extInfoOfImageList.imageBaseUrl = extInfoOfImageListNode.SelectSingleNode("imageBaseUrl").InnerText;

            response.Body.extInfoOfImageList.sizeCodeList.Items = new List<SizeCode>();
            XmlNodeList sizeCodeListNode = extInfoOfImageListNode.SelectNodes("sizeCodeList/sizeCode");
            for (var j = 0; j < sizeCodeListNode.Count; j++)
            {
                XmlNode sizeCodeNode = sizeCodeListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeList.Items.Add(sc);
            }

            response.Body.extInfoOfImageList.sizeCodeListWatermark.Items = new List<SizeCode>();
            XmlNodeList sizeCodeWatermarkListNode = extInfoOfImageListNode.SelectNodes("sizeCodeListWatermark/sizeCode");
            for (var j = 0; j < sizeCodeWatermarkListNode.Count; j++)
            {
                XmlNode sizeCodeWatermarkNode = sizeCodeWatermarkListNode[j];
                SizeCode sc = new SizeCode();
                sc.text = sizeCodeWatermarkNode.InnerText;
                response.Body.extInfoOfImageList.sizeCodeListWatermark.Items.Add(sc);
            }
            #endregion
            return response;
        }

        /// <summary>
        /// 获取酒店交通信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GetHotelTrafficInfoResponse GetHotelTrafficInfo(GetHotelTrafficInfoRequest request)
        {
            GetHotelTrafficInfoResponse response = new GetHotelTrafficInfoResponse();
            response.Body.trafficInfoList = new TrafficInfoList();

            ITcClient client = new DefaultTcClient();
            var responseXml = client.Execute(request);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseXml);

            #region parse header
            response.Header.actionCode = Tools.GetXmlDocumentInnerText(doc, "header/actionCode");
            response.Header.rspType = Tools.GetXmlDocumentInnerText(doc, "header/rspType");
            response.Header.rspCode = Tools.GetXmlDocumentInnerText(doc, "header/rspCode");
            response.Header.rspDesc = Tools.GetXmlDocumentInnerText(doc, "header/rspDesc");
            response.Header.rspTime = Tools.GetXmlDocumentInnerText(doc, "header/rspTime");
            #endregion

            #region parse trafficInfo
            response.Body.trafficInfoList.Items = new List<TrafficInfo>();
            XmlNodeList trafficInfoNodeList = doc.SelectNodes("//trafficInfo");
            for (var i = 0; i < trafficInfoNodeList.Count; i++)
            {
                var trafficInfoNode = trafficInfoNodeList[i];
                var trafficInfo = new TrafficInfo();
                trafficInfo.startLocation = Tools.GetXmlNodeInnerText(trafficInfoNode, "startLocation");
                trafficInfo.locationName = Tools.GetXmlNodeInnerText(trafficInfoNode, "locationName");
                trafficInfo.arrivalWay = Tools.GetXmlNodeInnerText(trafficInfoNode, "arrivalWay");
                trafficInfo.distance = Tools.GetXmlNodeInnerText(trafficInfoNode, "distance");
                response.Body.trafficInfoList.Items.Add(trafficInfo);
            }
            #endregion

            return response;
        }
    }
}
